{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">申请列表</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('banner.banner/add')}"
                   data-auth-edit="{:$auth->check('banner.banner/edit')}"
                   data-auth-delete="{:$auth->check('banner.banner/del')}"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="picTpl">
    <img style="max-width:100px; max-height:60px;" src="{{d.img}}" data-image="{{d.title}}">
</script>

<script type="text/html" id="barTool">


    <!--    {{# if(d.status==0){ }}-->
    <!--    <a href='{:url("refuse",["catid"=>$catid])}?ids={{ d.id }}'-->
    <!--       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">拨卡列表</a>-->
    <!--    {{# } }}-->
    {{# if(d.status==0||d.status==4){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("kb.boardbk/index")}?sq_id={{ d.id }}&shop_id={{d.shop_id}}'
       data-title="拨卡" data-full="true" >拨卡</a>
    {{# } }}

    {{# if(d.status==1||d.status==3){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("kb.boardbk/index2")}?sq_id={{ d.id }}&shop_id={{d.shop_id}}'
       data-title="拨卡记录" data-full="true" >拨卡记录</a>
    {{# } }}

    {{# if(d.status==4||d.status==1){ }}
    <a class="layui-btn layui-btn-xs" data-open='{:url("send")}?id={{ d.id }}' data-title="发货">发货</a>
    {{# }else{ }}
    <a class="layui-btn layui-btn-xs" data-open='{:url("send2")}?id={{ d.id }}' data-title="信息详情">信息详情</a>
    {{# } }}

    {{# if(d.status==0){ }}
    <a href='{:url("refuse",["catid"=>$catid])}?ids={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">拒绝</a>
    {{# } }}

</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="启动|关闭" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
        };
        table.render({
            init: init,
            toolbar: ['refresh'],
            // toolbar: ['refresh'],
            url: '{:url("index")}',
            search: true,
            cols: [
                [
                    //商家 数量 划拨数量 申请时间 划拨时间 接收时间 收货时间 实际拨卡 拒绝拨卡
                    {field: 'id', with: '8%', title: 'ID'},
                    {field: 'shop_name', align: "center", width: '15%', title: '所属店铺'},

                    {field: 'num', align: "center", width: '8%', title: '申请数量',search: false},
                    {field: 'send_num', align: "center", width: '8%', title: '发送数量',search: false},
                    {
                        field: 'status', width: '10%', align: "center", title: '划拨状态', templet: function (d) {
                            if (d.status == 0) {
                                return '<span style="color: green">待处理</span>';
                            } else if (d.status == 1) {
                                return '<span style="color: #00B83F">已发货</span>';
                            } else if (d.status == 2) {
                                return '<span style="color: red">拒绝</span>';
                            } else if (d.status == 3) {
                                return '<span style="color: #00a0e9">已收货</span>';
                            } else if (d.status == 4) {
                                return '<span style="color: #00a0e9">已拨卡</span>';
                            }
                        }, selectList: {0: '待处理', 1: '已发货', 2: '拒绝', 3: '已收货', 4: '已拨卡'}
                    },
                    {field: 'create_time', align: "center", width: '15%', title: '申请时间', search: 'range'},
                    {field: 'express_time', align: "center", width: '15%', title: '发货时间', search: 'range'},
                    {field: 'sh_time', align: "center", width: '15%', title: '收货时间', search: 'range'},
                    {fixed: 'right', width: '15%', align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}